<?php /*a:3:{s:68:"D:\phpstudy_pro\WWW\git\DSShop\app\admin\view\inviter\goods_add.html";i:1566788178;s:64:"D:\phpstudy_pro\WWW\git\DSShop\app\admin\view\public\header.html";i:1571626691;s:69:"D:\phpstudy_pro\WWW\git\DSShop\app\admin\view\public\admin_items.html";i:1566788179;}*/ ?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>DSShop单店铺商城系统后台</title>
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
        <link rel="stylesheet" href="<?php echo htmlentities(ADMIN_SITE_ROOT); ?>/css/admin.css">
        <link rel="stylesheet" href="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui/jquery-ui.min.css">
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery-2.1.4.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery.validate.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery.cookie.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/common.js"></script>
        <script src="<?php echo htmlentities(ADMIN_SITE_ROOT); ?>/js/admin.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui/jquery-ui.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui/jquery.ui.datepicker-zh-CN.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/perfect-scrollbar.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/layer/layer.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/dialog/dialog.js" id="dialog_js" charset="utf-8"></script>

        <script type="text/javascript">
            var BASESITEROOT = "<?php echo htmlentities(BASE_SITE_ROOT); ?>";
            var ADMINSITEROOT = "<?php echo htmlentities(ADMIN_SITE_ROOT); ?>";
            var BASESITEURL = "<?php echo htmlentities(BASE_SITE_URL); ?>";
            var HOMESITEURL = "<?php echo htmlentities(HOME_SITE_URL); ?>";
            var ADMINSITEURL = "<?php echo htmlentities(ADMIN_SITE_URL); ?>";
        </script>
    </head>
    <body>
        <div id="append_parent"></div>
        <div id="ajaxwaitid"></div>





<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3><?php echo htmlentities(lang('ds_inviter_set')); ?></h3>
                <h5></h5>
            </div>
            <?php if($admin_item): ?>
<ul class="tab-base ds-row">
    <?php if(is_array($admin_item) || $admin_item instanceof \think\Collection || $admin_item instanceof \think\Paginator): if( count($admin_item)==0 ) : echo "" ;else: foreach($admin_item as $key=>$item): ?>
    <li><a href="<?php echo htmlentities($item['url']); ?>" <?php if($item['name'] == $curitem): ?>class="current"<?php endif; ?>><span><?php echo htmlentities($item['text']); ?></span></a></li>
    <?php endforeach; endif; else: echo "" ;endif; ?>
</ul>
<?php endif; ?>
        </div>
    </div>
  <div class="fixed-empty"></div>
  
  <div class="dssc-form-default">
    <form id="add_form" method="post">
            
            <?php if(empty($goods_info) || (($goods_info instanceof \think\Collection || $goods_info instanceof \think\Paginator ) && $goods_info->isEmpty())): ?>
            <dl>
                <dt><i class="required">*</i><?php echo htmlentities(lang('inviter_goods')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
                <dd>
                    <div dstype="inviter_goods_info" class="selected-group-goods " style="display:none;">
                        <div class="goods-thumb"><img id="inviter_goods_image" src=""/></div>
                        <div class="goods-name">
                            <a dstype="inviter_goods_href" id="inviter_goods_name" href="" target="_blank"></a>
                        </div>
                        <div class="goods-price"><?php echo htmlentities(lang('mall_price')); ?>：￥<span dstype="inviter_goods_price"></span></div>
                    </div>
                    <a href="javascript:void(0);" id="btn_show_search_goods" class="dssc-btn dssc-btn-acidblue"><?php echo htmlentities(lang('choose_goods')); ?></a>
                    <input id="inviter_goods_commonid" name="inviter_goods_commonid" type="hidden" />
                    <span></span>
                    <div id="div_search_goods" class="div-goods-select mt10" style="display: none;">
                        <table class="search-form">
                            <tr>
                                <th class="w150">
                                    <strong><?php echo htmlentities(lang('search_items')); ?></strong>
                                </th>
                                <td class="w160">
                                    <input id="search_goods_name" type="text w150" class="text" name="goods_name" value=""/>
                                </td>
                                <td class="w70 tc">
                                    <a href="javascript:void(0);" id="btn_search_goods" class="dssc-btn"/><i class="iconfont">&#xe718;</i><?php echo htmlentities(lang('ds_search')); ?></a></td>
                                <td class="w10"></td>
                                <td>
                                    <p class="hint"></p>
                                </td>
                            </tr>
                        </table>
                        <div id="div_goods_search_result" class="search-result" style="width:739px;"></div>
                        <a id="btn_hide_search_goods" class="close" href="javascript:void(0);">X</a>
                    </div>
                    <p class="hint"></p>
                </dd>
            </dl>
            <?php else: ?>
            <dl>
                <dt><?php echo htmlentities(lang('inviter_goods')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
                <dd>
                    <?php echo htmlentities($goods_info['goods_name']); ?>
                    <input id="inviter_goods_commonid" name="inviter_goods_commonid" type="hidden" value="<?php echo htmlentities($goods_info['goods_commonid']); ?>" />
                </dd>
            </dl>
            <?php endif; ?>
            
            <dl>
                <dt><i class="required">*</i><?php echo htmlentities(lang('inviter_ratio_1')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
                <dd>
                    <input id="inviter_ratio_1" name="inviter_ratio_1" type="text" class="text w130" value="<?php echo htmlentities((isset($goods_info['inviter_ratio_1']) && ($goods_info['inviter_ratio_1'] !== '')?$goods_info['inviter_ratio_1']:'')); ?>"/><?php echo htmlentities(lang('ds_percent')); ?><span></span>
                    <p class="hint"><?php echo htmlentities(lang('cannot_exceed')); ?><?php echo htmlentities($config_inviter_ratio_1); ?><?php echo htmlentities(lang('ds_percent')); ?></p>
                </dd>
            </dl>
            <dl>
                <dt><i class="required">*</i><?php echo htmlentities(lang('inviter_ratio_2')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
                <dd>
                    <input id="inviter_ratio_2" name="inviter_ratio_2" type="text" class="text w130" value="<?php echo htmlentities((isset($goods_info['inviter_ratio_2']) && ($goods_info['inviter_ratio_2'] !== '')?$goods_info['inviter_ratio_2']:'')); ?>"/><?php echo htmlentities(lang('ds_percent')); ?><span></span>
                    <p class="hint"><?php echo htmlentities(lang('cannot_exceed')); ?><?php echo htmlentities($config_inviter_ratio_2); ?><?php echo htmlentities(lang('ds_percent')); ?></p>
                </dd>
            </dl>
            <dl>
                <dt><i class="required">*</i><?php echo htmlentities(lang('inviter_ratio_3')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
                <dd>
                    <input id="inviter_ratio_3" name="inviter_ratio_3" type="text" class="text w130" value="<?php echo htmlentities((isset($goods_info['inviter_ratio_3']) && ($goods_info['inviter_ratio_3'] !== '')?$goods_info['inviter_ratio_3']:'')); ?>"/><?php echo htmlentities(lang('ds_percent')); ?><span></span>
                    <p class="hint"><?php echo htmlentities(lang('cannot_exceed')); ?><?php echo htmlentities($config_inviter_ratio_3); ?><?php echo htmlentities(lang('ds_percent')); ?></p>
                </dd>
            </dl>
            
            <div class="bottom">
                    <input id="submit_button" type="submit" class="btn" value="<?php echo htmlentities(lang('ds_submit')); ?>">
            </div>
        </form>
</div>
<link rel="stylesheet" href="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.css">
<script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.js"></script>
<script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-zh-CN.js"></script>
<script>
    $(function () {
        
        $('#btn_show_search_goods').on('click', function() {
            $('#div_search_goods').show();
        });

        $('#btn_hide_search_goods').on('click', function() {
            $('#div_search_goods').hide();
        });
        //搜索商品
        $('#btn_search_goods').on('click', function() {
            var url = "<?php echo url('Inviter/search_goods'); ?>";
             var  datas  =  $.param({goods_name: $('#search_goods_name').val()});
            $('#div_goods_search_result').load(url,datas);
        });

        $('#div_goods_search_result').on('click', '.pagination li a', function() {
            $('#div_goods_search_result').load($(this).attr('href'));
            return false;
        });

        //选择商品
        $('#div_goods_search_result').on('click', '[dstype="btn_add_inviter_goods"]', function() {
            var goods_commonid = $(this).attr('data-goods-commonid');
            $.get("<?php echo url('Inviter/inviter_goods_info'); ?>", {goods_commonid: goods_commonid}, function(data) {
                if(data.result) {
                    $('#inviter_goods_commonid').val(data.goods_commonid);
                    $('#inviter_goods_image').attr('src', data.goods_image);
                    $('#inviter_goods_name').text(data.goods_name);
                    $('[dstype="inviter_goods_price"]').text(data.goods_price);
                    $('[dstype="inviter_goods_href"]').attr('href', data.goods_href);
                    $('[dstype="inviter_goods_info"]').show();
                    $('#div_search_goods').hide();
                } else {
                    layer.msg(data.message);
                }
            }, 'json');
        });
        
    <?php if(empty($goods_info) || (($goods_info instanceof \think\Collection || $goods_info instanceof \think\Paginator ) && $goods_info->isEmpty())): ?>
    $('#start_time').datetimepicker({dateFormat: 'yy-mm-dd'});
    $('#end_time').datetimepicker({dateFormat: 'yy-mm-dd'});
    <?php endif; ?>
        
        jQuery.validator.methods.greaterThanDate = function(value, element, param) {
            var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
            var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
            return date1 < date2;
        };

        jQuery.validator.methods.lessThanDate = function(value, element, param) {
            var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
            var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
            return date1 > date2;
        };

        jQuery.validator.methods.greaterThanStartDate = function(value, element) {
            var start_date = $("#start_time").val();
            var date1 = new Date(Date.parse(start_date.replace(/-/g, "/")));
            var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
            return date1 < date2;
        };

        jQuery.validator.methods.lessThanGoodsPrice= function(value, element) {
            var goods_price = $("#input_groupbuy_goods_price").val();
            return Number(value) < Number(goods_price);
        };
        
    //页面输入内容验证
    $("#add_form").validate({
            errorPlacement: function (error, element) {
                var error_td = element.parent('dd').children('span');
                error_td.append(error);
            },
            onfocusout: false,
            submitHandler: function (form) {
                ds_ajaxpost('add_form');
            },
                rules: {
                    inviter_goods_commonid: {
                        required: true
                    },
                    inviter_ratio_1: {
                        required: true,
                        number:true,
                        max : <?php echo htmlentities($config_inviter_ratio_1); ?>
                    },
                    inviter_ratio_2: {
                        required: true,
                        number:true,
                        max : <?php echo htmlentities($config_inviter_ratio_2); ?>
                    },
                    inviter_ratio_3: {
                        required: true,
                        number:true,
                        max : <?php echo htmlentities($config_inviter_ratio_3); ?>
                    },
                },
                messages : {
                    inviter_goods_commonid : {
                        required : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_goods_commonid_required')); ?>'
                    },
                    inviter_ratio_1: {
                        required: '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_ratio_1_required')); ?>',
                        number:'<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_ratio_1_number')); ?>',
                        max : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_ratio_1_max')); ?><?php echo htmlentities($config_inviter_ratio_1); ?><?php echo htmlentities(lang('ds_percent')); ?>'
                    },
                    inviter_ratio_2: {
                        required: '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_ratio_2_required')); ?>',
                        number:'<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_ratio_2_number')); ?>',
                        max : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_ratio_2_max')); ?><?php echo htmlentities($config_inviter_ratio_2); ?><?php echo htmlentities(lang('ds_percent')); ?>'
                    },
                    inviter_ratio_3: {
                        required: '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_ratio_3_required')); ?>',
                        number:'<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_ratio_3_number')); ?>',
                        max : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('inviter_ratio_3_max')); ?><?php echo htmlentities($config_inviter_ratio_3); ?><?php echo htmlentities(lang('ds_percent')); ?>'
                    },
            }
    });
    });
</script>
  
</div>  